﻿@using System.Web.Mvc.Ajax
@using System.Web.Mvc.Html
@using System.Web.Mvc;
@model WebUI.Models.FilesModel
<script src="@Links.Scripts.tooltip_js" type="text/javascript"></script>
<link href="@Links.Content.css.tooltip_css" rel="stylesheet" type="text/css" />
@if (Model.ShowChart)
{
    <img src="data:image/png;base64,@System.Convert.ToBase64String(Model.Chart)" alt="" />
}
@{
    if (Model.FilesList.Any())
    {
        var gridColumns = new List<WebGridColumn>();

        gridColumns.Add(new WebGridColumn
        {
            ColumnName = "ObjectName",
            Header = "File Name",
            CanSort = true,
            Format = @<text>@Html.Popup((string)item.ObjectName, MVC.Reports.Summary.Actions.ActionNames.FileSummary, (int)item.ID, 'f')</text>
        });

        gridColumns.Add(new WebGridColumn
        {
            ColumnName = "FullPathName",
            Header = "Directory Path",
            CanSort = true,
            Format = @<text>@Html.ToolTip((string)item.FullPathName, 10)</text>
        });
        gridColumns.Add(new WebGridColumn
        {
            ColumnName = "ServerName",
            CanSort = true,
            Format = @<text>@Html.Popup((string)item.ServerName, MVC.Reports.Summary.Actions.ActionNames.MachineTopAccessors, (int)item.ID, 's')</text>
        });

        gridColumns.Add(new WebGridColumn
        {
            ColumnName = "UserAccount",
            Header = "User",
            CanSort = true,
            Format = @<text>@Html.Popup((string)item.UserAccount, MVC.Reports.Summary.Actions.ActionNames.UserSummary, (int)item.ID, 'u')</text>
        });

        foreach (string column in Model.Columns.Keys)
        {
            if (Model.Columns[column])
            {
                gridColumns.Add(new WebGridColumn { ColumnName = column, CanSort = true });
            }
        }

        var grid = new WebGrid(ajaxUpdateContainerId: "grid", rowsPerPage: int.Parse(WebUI.Resources.PageSize));
        grid.Bind(source: Model.FilesList, autoSortAndPage: false, rowCount: Model.TotalCount);
    @grid.GetHtml(mode: WebGridPagerModes.All, htmlAttributes: new { id = "grid" }, tableStyle: "main_table", headerStyle: "columns_head",
 columns: gridColumns)
    }
    else
    {
    <p>
        No data found</p> 
    }
}
